package chabernac.android.wordbattle.paint.crosstile;

import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Point;
import android.graphics.Rect;
import android.graphics.RectF;
import android.view.View;
import chabernac.android.wordbattle.WordBattleView;
import chabernac.android.wordbattle.model.Word;
import chabernac.android.wordbattle.paint.iDrawable;

public abstract class AbstractCrossTileDrawable extends iDrawable{

	protected final Word mySelectedWord;
	
	public AbstractCrossTileDrawable(Word aSelectedWord)
	{
		super();
		mySelectedWord = aSelectedWord;
	}
	
	
	
	protected abstract Bitmap getBitmap(WordBattleView aWordBattleView);
	
	protected abstract Point getDrawingPoint(WordBattleView aWordBattleView);
	
	protected abstract Rect getBitmapSubsetRect(Bitmap aBitmap);
	
	@Override
	public void paint( Canvas aCanvas, View aView ) {
		Bitmap aBitmap = this.getBitmap((WordBattleView)aView);
		// Get the coordinates
		Point aPoint = this.getDrawingPoint((WordBattleView)aView);
		// Create the subset rectangle to draw: upper left corner
		Rect aSrcRect = this.getBitmapSubsetRect(aBitmap);
		// Create the rectangle to draw
		RectF aDestRect = new RectF(aPoint.x, aPoint.y, aPoint.x + aSrcRect.width(), aPoint.y + aSrcRect.height());
		// Draw the bitmap on the canvas
		aCanvas.drawBitmap(aBitmap, aSrcRect, aDestRect, null);
	}
}
